import request from '@/utils/request';
import type { PageResult } from '@/types/common';

export interface TeacherData {
  id: number;
  name: string;
  coursesTaught: string;
  professionalTitle: string;
  contactPhone: string;
  createTime: string;
  updateTime: string;
}

export interface TeacherQueryParams {
  search?: string;
  current: number;
  size: number;
}

export interface PageResult<T> {
  records: T[];
  total: number;
  size: number;
  current: number;
}

// 获取教师列表
export function getTeacherList(params: {
  current: number;
  size: number;
  search?: string;
}) {
  return request.get<PageResult<TeacherData>>('/api/staff/teacher/page', { params });
}

// 获取教师详情
export function getTeacherById(id: number) {
  return request.get<TeacherData>(`/api/staff/teacher/${id}`);
}

// 添加教师
export function addTeacher(data: Omit<TeacherData, 'id' | 'createTime' | 'updateTime'>) {
  return request.post<TeacherData>('/api/staff/teacher', data);
}

// 更新教师
export function updateTeacher(data: Partial<TeacherData>) {
  return request.put('/api/staff/teacher', data);
}

// 删除教师
export function deleteTeacher(id: number) {
  return request.delete(`/api/staff/teacher/${id}`);
}
